﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WebapiProjct001.DoMain.ENTITY

;
namespace WebapiProjct001.DoMain
{
    public class DbInitializeHelper
    {
        public static void Initialaze()
        {
            using (var db = new Admin4000DbContext())
            {
               var Eist= db.Database.EnsureCreated();
                if (!Eist)
                {
                    var Bran = new Brand
                    {
                        BrandName = "华为",
                        Description = "中国的龙头企业！"
                    };
                    db.Brands.Add(Bran);
                    db.SaveChanges();
                    db.Products.AddRange(new Product[] {
                    new Product
                    {
                         ProductName = "HuaWei mate20",
                        ShortDesc = "mate 系列",
                        FullDesc = "华为旗舰机型",
                        BrandId = Bran.Id
                    }


                 });
                    db.SaveChanges();
                }
                
            }   
        }
    }
}
